package com.example.farmer.Adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.farmer.Fragment.Class.AnimalPlantEpidemicFragment;
import com.example.farmer.Fragment.Class.ExpertConsultationsFragment;
import com.example.farmer.Fragment.Class.NewsFragment;
import com.example.farmer.Fragment.Class.PosterCircleNewsFragment;
import com.example.farmer.Fragment.Class.ScienceEncyclopediaFragment;
import com.example.farmer.Fragment.Class.StartupProjectsFragment;
import com.example.farmer.Fragment.Class.WeatherForecastFragment;
import com.example.farmer.Fragment.ClassFragment;

import java.util.List;

public class ViewPagerClassAdapter extends FragmentStateAdapter {
    private List<String> newsList;
//    private List<String> consultationsList;
    private List<String> posterCircleNewsList;
    private List<String> startupProjectsList;
    private List<String> animalPlantEpidemicList;
    private List<String> scienceEncyclopediaList;
    private List<String> weatherForecastList;

    public ViewPagerClassAdapter(@NonNull ClassFragment fa) {
        super(fa);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return NewsFragment.newInstance(newsList);
//            case 1:
//                return ExpertConsultationsFragment.newInstance(consultationsList);
            case 1:
                return PosterCircleNewsFragment.newInstance(posterCircleNewsList);
            case 2:
                return StartupProjectsFragment.newInstance(startupProjectsList);
            case 3:
                return AnimalPlantEpidemicFragment.newInstance(animalPlantEpidemicList);
            case 4:
                return ScienceEncyclopediaFragment.newInstance(scienceEncyclopediaList);
            case 5:
                return WeatherForecastFragment.newInstance(weatherForecastList);
            default:
                return new Fragment(); // 默认返回一个空Fragment
        }
    }

    @Override
    public int getItemCount() {
        // 返回Tab的数量
        return 6;
    }

    // 为每个列表设置数据的方法
    public void setNewsList(List<String> newsList) {
        this.newsList = newsList;
    }

//    public void setConsultationsList(List<String> consultationsList) {
//        this.consultationsList = consultationsList;
//    }

    public void setPosterCircleNewsList(List<String> posterCircleNewsList) {
        this.posterCircleNewsList = posterCircleNewsList;
    }

    public void setStartupProjectsList(List<String> startupProjectsList) {
        this.startupProjectsList = startupProjectsList;
    }

    public void setAnimalPlantEpidemicList(List<String> animalPlantEpidemicList) {
        this.animalPlantEpidemicList = animalPlantEpidemicList;
    }

    public void setScienceEncyclopediaList(List<String> scienceEncyclopediaList) {
        this.scienceEncyclopediaList = scienceEncyclopediaList;
    }

    public void setWeatherForecastList(List<String> weatherForecastList) {
        this.weatherForecastList = weatherForecastList;
    }

}